/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.fty.service;

import java.util.List;

import com.jeesite.common.lang.DateUtils;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.sys.entity.Employee;
import com.jeesite.modules.sys.entity.Office;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.fty.entity.FtySelContract;
import com.jeesite.modules.fty.dao.FtySelContractDao;

/**
 * 合同表Service
 * @author chensk
 * @version 2018-04-17
 */
@Service
@Transactional(readOnly=true)
public class FtySelContractService extends CrudService<FtySelContractDao, FtySelContract> {

	public void addDataScopeFilter(FtySelContract ftySelContract, String ctrlPermi) {

		ftySelContract.getSqlMap().getDataScope().addFilter("dsfOffice", "Office", "e.office_code", ctrlPermi);

	}


	/**
	 * 获取单条数据
	 * @param ftySelContract
	 * @return
	 */
	@Override
	public FtySelContract get(FtySelContract ftySelContract) {
		return super.get(ftySelContract);
	}

	/**
	 * 查询分页数据
	 * @param page 分页对象
	 * @param ftySelContract
	 * @return
	 */
	@Override
	public Page<FtySelContract> findPage(Page<FtySelContract> page, FtySelContract ftySelContract) {
		return super.findPage(page, ftySelContract);
	}

	/**
	 * 保存数据（插入或更新）
	 * @param ftySelContract
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(FtySelContract ftySelContract) {
		super.save(ftySelContract);
	}

	/**
	 * 更新状态
	 * @param ftySelContract
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(FtySelContract ftySelContract) {
		super.updateStatus(ftySelContract);
	}

	/**
	 * 删除数据
	 * @param ftySelContract
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(FtySelContract ftySelContract) {
		super.delete(ftySelContract);
	}
	@Transactional(readOnly=false)
	public void generalUUid(FtySelContract ftySelContract) {

		String topIndex = dao.selectTopIndex();
		String date = DateUtils.getDate("yyyy");
		if(!topIndex.startsWith(date)){
			dao.generalcnN1(ftySelContract);
		}else{
			dao.generalcn(ftySelContract);
		}


	}
}